/**
 * Copyright (c) 2024 - CARThunder
 * All Rights Reserved by Chengdu CARThunder Intelligent Technology Co., LTD and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with CARThunder in writing by applicable law.
 * <p>
 * <p>
 * file description.
 *
 * @file filename
 * @brief brief function description.
 * @details detailed function description.
 * @version 1.0
 * @author author_name
 * @date last_modified_date
 * <p>
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-07-30              junjieluo         Create it.
 * <p>
 * file description.
 * @file filename
 * @brief brief function description.
 * @details detailed function description.
 * @version 1.0
 * @author author_name
 * @date last_modified_date
 * <p>
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-07-30              junjieluo         Create it.
 */

/**
 * file description.
 * @file filename
 * @brief brief function description.
 * @details detailed function description.
 * @version 1.0
 * @author author_name
 * @date last_modified_date
 *
 *      Edit History
 *      ----------------------------------------------------------------------------
 *      DATE                     NAME               DESCRIPTION
 *      2024-07-30              junjieluo         Create it.
 *
 */


package com.cart.musicdemo.model;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * The type Song model.
 */
public class SongModel implements Parcelable {
    // 歌曲的名称
    private String name;

    // 歌曲的封面图像
    private Bitmap bitmap;

    // 歌手的名字
    private String singer;

    // 专辑的名字
    private String album;

    // 歌曲文件的路径
    private String path;

    // 歌曲的持续时间，以毫秒为单位
    private int duration;

    // 歌曲文件的大小，以字节为单位
    private long size;

    // 指示歌曲是否正在播放的状态
    private Boolean isPlaying = false;


    /**
     * Instantiates a new Song model.
     *
     * @param in the in
     */
    public SongModel(Parcel in) {
        name = in.readString();
        bitmap = in.readParcelable(Bitmap.class.getClassLoader());
        singer = in.readString();
        album = in.readString();
        path = in.readString();
        duration = in.readInt();
        size = in.readLong();
        byte tmpIsPlaying = in.readByte();
        isPlaying = tmpIsPlaying == 0 ? null : tmpIsPlaying == 1;
    }

    /**
     * Instantiates a new Song model.
     */
    public SongModel() {

    }

    /**
     * The constant CREATOR.
     */
    public static final Creator<SongModel> CREATOR = new Creator<SongModel>() {
        @Override
        public SongModel createFromParcel(Parcel in) {
            return new SongModel(in);
        }

        @Override
        public SongModel[] newArray(int size) {
            return new SongModel[size];
        }
    };

    /**
     * Gets name.
     *
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * Sets name.
     *
     * @param name the name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Gets bitmap.
     *
     * @return the bitmap
     */
    public Bitmap getBitmap() {
        return bitmap;
    }

    /**
     * Sets cover image.
     *
     * @param bitmap the bitmap
     */
    public void setBitmap(Bitmap bitmap) {
        this.bitmap = bitmap;
    }

    /**
     * Gets singer.
     *
     * @return the singer
     */
    public String getSinger() {
        return singer;
    }

    /**
     * Sets singer.
     *
     * @param singer the singer
     */
    public void setSinger(String singer) {
        this.singer = singer;
    }

    /**
     * Gets album.
     *
     * @return the album
     */
    public String getAlbum() {
        return album;
    }

    /**
     * Sets album.
     *
     * @param album the album
     */
    public void setAlbum(String album) {
        this.album = album;
    }

    /**
     * Gets path.
     *
     * @return the path
     */
    public String getPath() {
        return path;
    }

    /**
     * Sets path.
     *
     * @param path the path
     */
    public void setPath(String path) {
        this.path = path;
    }

    /**
     * Gets duration.
     *
     * @return the duration
     */
    public int getDuration() {
        return duration;
    }

    /**
     * Sets duration.
     *
     * @param duration the duration
     */
    public void setDuration(int duration) {
        this.duration = duration;
    }

    /**
     * Gets size.
     *
     * @return the size
     */
    public long getSize() {
        return size;
    }

    /**
     * Sets size.
     *
     * @param size the size
     */
    public void setSize(long size) {
        this.size = size;
    }

    /**
     * Sets playing.
     *
     * @param playing the playing
     */
    public void setPlaying(Boolean playing) {
        isPlaying = playing;
    }

    /**
     * Gets playing.
     *
     * @return the playing
     */
    public Boolean getPlaying() {
        return isPlaying;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(name);
        parcel.writeParcelable(bitmap, i);
        parcel.writeString(singer);
        parcel.writeString(album);
        parcel.writeString(path);
        parcel.writeInt(duration);
        parcel.writeLong(size);
        parcel.writeByte((byte) (isPlaying == null ? 0 : isPlaying ? 1 : 2));
    }

    /**
     * override equals.
     *
     * @param o object
     * @return boolean
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        SongModel songModel = (SongModel) o;

        // 检查所有重要属性是否相等
        return this.name.equals(songModel.name)
                && this.singer.equals(songModel.singer)
                && this.path.equals(songModel.path);
    }

    /**
     * override hash.
     *
     * @return hash
     */
    @Override
    public int hashCode() {
        return Objects.hash(name, bitmap, singer, album, path, duration, size, isPlaying);
    }
}

